export default {
  data(){
    return {
      statusCode:''
    }
  },
  methods: {
    /**
     * @param {返回结果集} res
     */
    checkCode(res) {
      if (res.code == 401) {
        this.$message.error(res.msg);
        this.$router.push({ name: "login" });
        this.$store.commit('logout')
      }
      console.log(res.log,"msg")
      if (res && res.msg!='' &&res.msg!=undefined && res.code == 200) this.$message({
        message: res.msg,
        type: res.code == 200 ? "success" : "error",
      });
      this.statusCode = res.code
      return this
    },
    /**
     * 状态码为200时
     * @param {执行方法} fn
     */
    success(fn){
      if (this.statusCode == 200) fn()
      return this
    }
  },
};